package com.elsemodular.meeting.action;

import javax.annotation.Resource;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Result;
import com.base.common.action.AbstractBaseAction;
import com.base.common.persistent.model.MeetingConfig;
import com.elsemodular.meeting.service.MeetingService;

//@Action("")
/*@Results({ @Result(name = ASYNCHRONOUS, type = JSON, params = { ROOT,
		ACTION_RESULT_DATA, CONTENT_TYPE, CONTENT_TYPE_JSON }) })*/
public class MeetingAction extends AbstractBaseAction {

	private static final long serialVersionUID = 1L;
	
	@Resource
	private MeetingService meetingServiceImpl;

	private String code;
	
	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}

	
	@Action(value="/queryMeeingConfig", results = {@Result(name = SUCCESS, type="dispatcher", location = "/page/meeting/index.jsp")})
	public String queryMeeingConfig() {
		try {
			MeetingConfig config = meetingServiceImpl.queryMeetingConfig(code.trim());
			request.setAttribute("title", config.getMeetingTitle());
			request.setAttribute("meetingId", config.getMeetingId());
			request.setAttribute("bgUrl", config.getMeetingBgUrl());
			request.setAttribute("QRCodesUrl", config.getQRCodesUrl());
			request.setAttribute("address", config.getMeetingAddress());
		} catch (Exception e) {
			e.printStackTrace();
			return "nopermission";
		}
		return SUCCESS;
	}
	
}
